(function (window){
	var interface_facebook;
	function FacebookInterface (gameWidth, gameHeight) {
		this.gameHeight = gameHeight;
		this.gameWidth = gameWidth; 
	}

	FacebookInterface.prototype = new createjs.Container();
	FacebookInterface.prototype.Container_initialize = FacebookInterface.prototype.initialize();
	// hàm khởi tạo
	FacebookInterface.prototype.initialize = function(){
		//Initial all of resources for this class
		this.mainImg 			= this.load(contentmanager.bg_main, this.gameWidth/2, this.gameHeight/2);
		this.facebookImg 		= this.load(contentmanager.btn_connect_facebook, this.gameWidth/2, this.gameHeight/2, 0.8, 0.8);

		var text = new Text("0",'bold 30px Arial', '#000');
		text.x = 527;
		text.y = 16;
		text.alpha = 0.8
		this.addChild(text);
		
		var text = new Text("Bạn phải đăng nhập để chơi và lưu lại câu hỏi",'bold 20px Arial', '#fff');
		text.x = 150;
		text.y = 190;
		text.alpha = 0.8
		this.addChild(text);
		
		interface_facebook = this;
		var self = this;
		this.facebookImg.addEventListener("mousedown", self.mouseDown);
		this.facebookImg.addEventListener("mouseover", self.mouseOver);
		this.facebookImg.addEventListener("mouseout", self.mouseOut);
	}	

	FacebookInterface.prototype.load = function (data, x, y, scaleX, scaleY) {
		var bitmap = new createjs.Bitmap(data);
		var width = bitmap.image.width;
		var height = bitmap.image.height;
		bitmap.x = x || 0;
		bitmap.y = y || 0;
		bitmap.regX = width/2;
		bitmap.regY = height/2;
		bitmap.scaleX = scaleX || 1;
		bitmap.scaleY = scaleY || 1;
		bitmap.width = width*bitmap.scaleX;
		bitmap.height = height*bitmap.scaleY;
		this.addChild(bitmap);
		return bitmap;
	}
	
	//Kết nối đến facebook
	FacebookInterface.prototype.tryConnectFacebook = function() {
		FB.login(function(response) {
		}, {scope: 'publish_actions, user_photos, publish_stream', return_scopes: true});
	}
	
	FacebookInterface.prototype.mouseDown = function() {
		var self = interface_facebook;
		self.tryConnectFacebook();
	}
	FacebookInterface.prototype.mouseOver = function() {
		var self = interface_facebook;
		createjs.Tween.get(self.facebookImg).to({scaleX: self.facebookImg.scaleX + 0.1,scaleY:self.facebookImg.scaleY + 0.1},200);
	}
	FacebookInterface.prototype.mouseOut = function() {
		var self = interface_facebook;
		createjs.Tween.get(self.facebookImg).to({scaleX: self.facebookImg.scaleX - 0.1,scaleY:self.facebookImg.scaleY - 0.1},200);
	}
	
	window.FacebookInterface = FacebookInterface;
}(window));